<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>坤哥图书</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            background: linear-gradient(to right, #6a11cb, #2575fc);
            color: #333;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
            box-sizing: border-box;
        }
        .container {
            background-color: #ffffff;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
            width: 90%;
            max-width: 1200px;
            margin-top: 20px;
            box-sizing: border-box;
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 25px;
            font-size: 2.5em;
            font-weight: 700;
        }
        .welcome-message {
            text-align: center;
            margin-bottom: 25px;
            font-size: 1.3em;
            color: #555;
            font-weight: 500;
        }
        .button-container {
            display: flex;
            justify-content: center;
            align-items: center;
            flex-wrap: wrap;
            margin-bottom: 25px;
            gap: 15px;
        }
        .button {
            background-color: #007bff;
            color: white;
            padding: 12px 25px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            text-decoration: none;
            font-size: 1.1em;
            transition: background-color 0.3s ease, transform 0.2s ease;
            box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
        }
        .button:hover {
            background-color: #0056b3;
            transform: translateY(-2px);
        }
        input[type="text"] {
            padding: 10px 15px;
            width: 280px;
            border: 1px solid #ccc;
            border-radius: 6px;
            font-size: 1em;
            box-sizing: border-box;
            transition: border-color 0.3s ease;
        }
        input[type="text"]:focus {
            border-color: #007bff;
            outline: none;
        }

        .search-and-logout-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
            gap: 15px; /* Add some space between elements */
        }

        @media (max-width: 768px) {
            .search-and-logout-container {
                flex-direction: column;
                align-items: stretch;
            }
            .search-form,
            .logout-form {
                width: 100%;
                justify-content: center;
            }
            .search-form input[type="text"] {
                width: 100%;
            }
        }

        .search-form {
            display: flex;
            align-items: center;
            gap: 10px; /* Space between input and search button */
        }

        .logout-form {
            display: flex;
            align-items: center;
        }

        table {
            width: 100%;
            margin: 25px auto;
            border-collapse: collapse;
            box-shadow: 0 8px 20px rgba(0,0,0,0.1);
            background-color: #fff;
            border-radius: 10px;
            overflow: hidden;
        }
        th, td {
            padding: 15px 20px;
            border-bottom: 1px solid #eee;
            text-align: left;
            font-size: 1em;
        }
        th {
            background-color: #007bff;
            color: white;
            font-weight: 600;
            text-transform: uppercase;
        }
        tr:nth-child(even) {
            background-color: #f8f9fa;
        }
        tr:hover {
            background-color: #e2f0ff;
            transition: background-color 0.2s ease;
        }
        td {
            color: #333;
        }
        @media (max-width: 768px) {
            .button-container {
                flex-direction: column;
            }
            input[type="text"] {
                width: 100%;
            }
            table, thead, tbody, th, td, tr {
                display: block;
            }
            thead tr {
                position: absolute;
                top: -9999px;
                left: -9999px;
            }
            tr {
                border: 1px solid #ccc;
                margin-bottom: 10px;
                border-radius: 8px;
            }
            td {
                border: none;
                border-bottom: 1px solid #eee;
                position: relative;
                padding-left: 50%;
                text-align: right;
            }
            td:before {
                position: absolute;
                top: 0;
                left: 6px;
                width: 45%;
                padding-right: 10px;
                white-space: nowrap;
                text-align: left;
                font-weight: 600;
                color: #555;
            }
            td:nth-of-type(1):before { content: "ID:"; }
            td:nth-of-type(2):before { content: "书名:"; }
            td:nth-of-type(3):before { content: "作者:"; }
            td:nth-of-type(4):before { content: "ISBN:"; }
            td:nth-of-type(5):before { content: "价格:"; }
            td:nth-of-type(6):before { content: "位置:"; }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>坤哥图书</h1>
        <p class="welcome-message">欢迎你, <span th:text="${username}"></span>!</p>

        <div class="button-container">

            <div class="search-and-logout-container">
                <form th:action="@{/user/dashboard}" method="get" class="search-form">
                    <input type="text" name="keyword" placeholder="搜索书名、作者或ISBN">
                    <button type="submit" class="button">搜索</button>
                </form>
                <form th:action="@{/logout}" method="post" class="logout-form">
                    <button type="submit" class="button">退出登录</button>
                </form>
            </div>
        </div>

        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>书名</th>
                    <th>作者</th>
                    <th>ISBN</th>
                    <th>价格</th>
                    <th>位置</th>

                </tr>
            </thead>
            <tbody>
                <tr th:each="book : ${books}">
                    <td th:text="${book.id}"></td>
                    <td th:text="${book.title}"></td>
                    <td th:text="${book.author}"></td>
                    <td th:text="${book.isbn}"></td>
                    <td th:text="${book.price}"></td>
                    <td th:text="${book.location}"></td>

                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>